package com.diko.configuration;

import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import org.springframework.boot.CommandLineRunner;

import java.util.Objects;

/**
 * @author Emma Li
 * @date 2020/10/23 - 16:51
 */
@SuppressWarnings("unused")
public class CustomCommandLineRunner implements CommandLineRunner {
    Environment env;

    public CustomCommandLineRunner(Environment env) {
        this.env = env;
    }

    @Override
    public void run(String... args) throws Exception {
        System.out.println("利用spring boot自动装配得CommandLineRunner");

        System.out.println("生成一个随机字符串：".concat(Objects.requireNonNull(env.getProperty("random."))));
    }
}

